/*
* drive.h - this file prototypes communication between mod chip and drive chip
* Copyright 2006-2008 OpenWii (admin@openwii.org)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* Version 2.4 by Andii
*/

#ifndef DRIVE_H
#define DRIVE_H

enum SpeedByte
{
	AFX_SWITCH			= 0x01,	// bit 0 disables audiofix if set
	SPEED_MASK			= 0xf0	// drive speed is in the upper nibble
};

enum ConfigCommands
{
	CONFIG_JAP_R		= 0x00,	// Japan region
	CONFIG_USA_R		= 0x01,	// USA region
	CONFIG_PAL_R		= 0x02,	// PAL (Europ) region
	CONFIG_res_R		= 0x03,	// reserved (means CONFIG_OFF_R)
	CONFIG_OFF_R		= 0x04,	// region patching off

	CONFIG_AFX_ON		= 0x07,	// switch on audiofix
	CONFIG_AFX_OFF		= 0x08,	// switch off audiofix
	CONFIG_UPDATE		= 0x09,	// start the bootloader update

	CONFIG_SLOW_SPEED	= 0x30,	// 3x drive speed
	CONFIG_MAX_SPEED	= 0x60,	// 6x drive speed

	CONFIG_MAGIC		= 0xa5	// signature written to the high byte of CONFIG_XFER
};

// drive chip locations (must match .jsym files)
enum DriveAddress
{
	REGION_XFER		= 0x8100,	// byte address used to transfer region data to dvd drive
	SPEED_XFER		= 0x8101,	// byte address used to transfer speed / audiofix data to dvd drive
	CONFIG_XFER		= 0x8120,	// word address used to read configuration commands from dvd drive
	STACK_RET		= 0x8f84,	// stack address where to inject the firmware
	DRIVE_CODE		= 0x408000,	// firmware address
	DRIVE_TYPE		= 0x40bca6,	// drive type dms/d2b address
	FLASH_UPDATE	= 0x40C000	// address to transfer firmware update
};

enum DICommands
{
	DI_REPORTDISCKEY	= 0xa4,	// SMG check
	DI_READSECTOR		= 0xa8,	// read sector
	DI_SETUPDATEDATA	= 0x69,	// send firmware data to the drive chip
	DI_CONFIGCOMMAND	= 0xe9	// send a configuration command to the mod chip
};

#endif	// DRIVE_H
